Auth()
//用户名
var username;
var reg0 = /^[a-zA-Z0-9_-]{4,16}$/;
var bol0 = false;
$("#username").on('blur', function() {
	if($("#username").val() == '') {
		tips('用户名不能为空');
		bol0 = false;
	} else if(reg0.test($("#username").val()) == false) {
		tips('用户名格式不正确');
		bol0 = false;
	} else {
		username = $("#username").val();
		bol0 = true;
	};
});
//手机号码
var re_phone;
var reg5 = /^1(3|4|5|7|8|9)\d{9}$/;
var bol1 = false;
$("#phone").on('blur', function() {
	if($("#phone").val() == '') {
		tips('手机号不能为空');
		bol1 = false;
	} else if(reg5.test($("#phone").val()) == false) {
		tips("手机号格式不正确");
		bol1 = false;
	} else {
		re_phone = $("#phone").val();
		console.log(re_phone)
		bol1 = true;
	};
});
//密码
var password;
var reg1 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
var bol2 = false;
$("#password").on('blur', function() {
	if($("#password").val() == '') {
		tips('密码不能为空');
		bol2 = false;
	} else if(reg1.test($("#password").val()) == false) {
		tips('密码格式不能为空');
		bol2 = false;
	} else {
		password = $("#password").val();
		bol2 = true;
	};
});
//验证码
var re_code;
var bol3 = false;
$("#code").on('blur', function() {
	if($("#code").val() == '') {
		tips('验证码不能为空');
		bol3 = false;
	}else {
		re_code = $("#code").val();
		console.log(re_code)
		bol3 = true;
	};
});
//发送验证码
var time = 60;
$('#sendCode').on('click', function() {
	console.log(111)
	if(bol0 && bol1 && bol2 && $('#sendCode').hasClass('sendCode')) {
		console.log(222)
		$.post(apicom + '/sms/sendSms', {
			phone: $('#phone').val()
		}, function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res)
			}
			tips(res.message);
			if(res.code == 200) {
				$('#sendCode').removeClass('sendCode')
				var timer = setInterval(function() {
					time--;
					if(time <= 0) {
						time = 60;
						$('#sendCode').html('发送验证码');
						clearInterval(timer);
						$('#sendCode').addClass('sendCode');
					} else {
						$('#sendCode').html(time + '秒')
					}
				}, 1000)

			}
		})
	}
})

//设置密码
$('#btn_tj').on('click', function() {
	if(bol0 && bol1 && bol2 && bol3) {
		var repsdObj = {
			phone: re_phone,
			userName: username,
			code: re_code,
			newPassword: password
		};
		console.log(repsdObj)
		$.ajax({
			type: "post",
			url: apicom + "/sms/checkSms",
			async: true,
			data: repsdObj,
			success: function(res) {
				if(res.code==200){
					$('.mengban').css('display', 'block');
				}else{
					tips(res.message)
				}
			},
			error: function(err) {
				console.log(err)
			}

		});
	}else{
		tips('请检查信息是否填写完整')
	}

})
$('.btn_close').on('click', function() {
	$('.mengban').css('display', 'none');
	localStorage.clear();
	window.location.href='login.html'
	
})
$('.close_s').on('click', function() {
	$('.mengban').css('display', 'none');
})